package com.kun.demo02;


import org.junit.Test;

// 测试携带参数的lambda表达式
public class TestLambda02 {

    @Test
    public void test() {
        // 带参数的lambda表达式
        LambdaInterface02 lambdaInterface02 = (int a)->{
            System.out.println("a = " + a);
        };
        lambdaInterface02.method(10);
    }

    @Test
    public void test2() {
        // 省略参数类型
        LambdaInterface02 lambdaInterface02 = (a)->{
            System.out.println("a = " + a);
        };
        lambdaInterface02.method(10);
    }

    @Test
    public void test3() {
        // 省略参数类型和括号
        LambdaInterface02 lambdaInterface02 = a-> {
            System.out.println("a = " + a);
        };
        lambdaInterface02.method(10);
    }

    @Test
    public void test4() {
        // 省略参数类型和括号
        LambdaInterface02 lambdaInterface02 = a-> System.out.println("a = " + a);
        lambdaInterface02.method(10);
    }

    @Test
    public void test5() {
        Runnable runnable = ()-> System.out.println("Hello Lambda!");
        new Thread(runnable).start();
    }


}


interface LambdaInterface02 {

    public void method(int a);

}
